Logic circuit and method for performing AES MixColumn transform

ABSTRACT

A logic circuit having structure for performing the AES Rijndael MixColumns transform exploits the relationship between each successive row of the transform matrix and its preceding row. Multiplication of an (m.times.n) matrix by a (1.times.n) or by a (m.times.1) matrix is performed, where m is a number of rows and n is a number of columns, and where each successive row, m, of n elements is a predetermined row permutation of a preceding row, includes: n multiplication circuits; n logic circuits; n registers for receiving logical output from the logic circuits; feedback logic for routing contents of each register to a selected one of inputs of the logic circuits in accordance with a feedback plan that corresponds to the relationship between successive matrix rows; and a control unit for successively providing as input to each of the n multiplication circuits each element in the (1.times.n) or (m.times.1) matrix.

The present invention relates to methods and apparatus for implementation of the Advanced Encryption Standard (AES) algorithm and in particular to methods and apparatus for performing the matrix multiplication operation that constitutes the AES MixColumn transformation in each of the encryption and decryption rounds of the algorithm.

The invention has particular, though not exclusive, application in cryptographic devices such as those installed in smart cards and other devices where processor and memory resources are somewhat limited and many operations of the cryptographic algorithm are performed in dedicated ASIC or FPGA hardware.

The AES algorithm has wide application in the encryption of data to be transmitted in a secure fashion. One application is in the transmittal of personal and/or financial information from a smartcard to a card reader device. Confidential data stored on the card must not be retrieved from the card except in encrypted form to ensure that the data so retrieved cannot be intercepted and read by an unauthorised third party. Only the authorised reader is able to decrypt the data retrieved from the card.

Similarly, data supplied by the card reader to be stored in the card must be passed to the card in encrypted form, and decrypted by the card for storage and subsequent retrieval.

While the AES algorithm is relatively straightforward to implement in a conventional computer system deploying state of the art processor and memory circuits, in a smartcard application, the processor and memory resource is very limited, and many functions must be executed in dedicated hardware, such as ASICs or FPGAs.

There is therefore a requirement for hardware implementations of the procedures required in the AES algorithm which implementations require the minimum use of hardware resource.

It is an object of the present invention to provide suitable circuitry for effecting the MixColumn transform deployed in the standard AES (Rijndael) cryptographic algorithm, both for encryption and decryption.

According to one aspect, the present invention provides a logic circuit for multiplication of an (m×n) matrix by a (1×n) or by a (m×1) matrix, where m is a number of rows and n is a number of columns, and wherein each successive row m, of n elements is a predetermined row permutation of a preceding row, the circuit comprising:

n multiplication circuits each having an input and an output which returns the value of said input multiplied by a predetermined multiplicand;

n logic circuits, each for executing a predetermined logical combination of a first input and a second input to provide a logical output, the first input being coupled to the output of a corresponding one of the n multiplication circuits;

n registers for receiving said logical output;

feedback logic for routing the contents of each register to a selected one of the second inputs in accordance with a feedback plan that corresponds to the predetermined row permutation; and

control means for successively providing as input to each of the n multiplication circuits each element in the (1×n) or (m×1) matrix.

Embodiments of the present invention will now be described by way of example and with reference to the accompanying drawings in which:

FIG. 1 is a flow diagram illustrating implementation of an encryption operation using the AES block cipher algorithm; and

FIG. 2 is a schematic diagram of a functional logic block for performing the MixColumns transform.

The AES algorithm for encryption of plaintext to ciphertext is shown in FIG. 1. The AES algorithm may be implemented using a 128-bit, a 192-bit or a 256-bit key operating on successive 128-bit blocks of input data. The present invention is applicable to all of these implementations. FIG. 1 will now be described in the context of the basic implementation using a 128-bit key.

An initial 128-bit block of input plaintext 10 is XOR-combined 11 with an original 128-bit key 12 in an initial round 15. The output 13 from this initial round 15 is then passed through a number of repeated transform stages, in an encryption round 28 which includes the SubBytes transform 20, the ShiftRows transform 21 and the MixColumns transform 22 in accordance with the defined AES algorithm.

The output from the MixColumns transform 22 is XOR-combined 23 with a new 128-bit round key 26, which has been derived 25 from the initial (original) key 12. The output from this XOR-combination 23 is fed back to pass through the encryption round 28 a further number of times, the number depending upon the particular implementation of the algorithm.

For each successive iteration through the encryption round 28, a new round key 26′ is derived from the existing round key 26 according to the AES round key schedule.

The number of iterations (Nr-1) of the encryption round 28 is nine where a 128-bit encryption key is being used, eleven where a 192-bit encryption key is being used, and thirteen where a 256-bit encryption key is being used.

After the requisite number (Nr-1) of encryption rounds 28, a final round, Nr, is entered under the control of decision box 24. The final round 30 comprises a further SubBytes transform 31, a further ShiftRows transform 32, and a subsequent XOR-combination 33 of the result with a final round key 36 generated 35 from the previous round key. The output therefrom comprises the ciphertext output 39 of the encryption algorithm.

The present invention relates particularly to the performing of the MixColumns transform 22. Through the rounds 28, 30, the 128-bit blocks being processed are conveniently represented as 16 8-bit blocks in a 4×4 matrix, as s_(row, column,) according to the pattern,

S_(0,0) S_(0,1) S_(0,2) S_(0,3) S_(1,0) S_(1,1) S_(1,2) S_(1,3) S_(2,0) S_(2,1) S_(2,2) S_(2,3) S_(3,0) S_(3,1) S_(3,2) S_(3,3)

In the MixColumns transform 22, the columns of this state are considered as polynomials over GF(2⁸) and multiplied modulo (X⁴+1) with a predetermined fixed polynomial a(x), given by: a(x)=a ₃ x ³ +a ₂ x ² +a ₁ x+a ₀, in which, represented as hexadecimal values,

a₃=03 h

a₂=01 h

a₁=01 h

a₀=02 h.

The polynomial is co-prime to x⁴+1 and is therefore invertible.

For encryption, the MixColumns transform can therefore be expressed as s_(r,c)→s′_(r,c), for each of the columns in s.

$\begin{pmatrix} S_{0,c}^{\prime} \\ S_{1,c}^{\prime} \\ S_{2,c}^{\prime} \\ S_{3,c}^{\prime} \end{pmatrix} = {{\begin{pmatrix} a_{0} & a_{3} & a_{2} & a_{1} \\ a_{1} & a_{0} & a_{3} & a_{2} \\ a_{2} & a_{1} & a_{0} & a_{3} \\ a_{3} & a_{2} & a_{1} & a_{0} \end{pmatrix}\begin{pmatrix} S_{0,c} \\ S_{1,c} \\ S_{2,c} \\ S_{3,c} \end{pmatrix}} = {\begin{pmatrix} 02 & 03 & 01 & 01 \\ 01 & 02 & 03 & 01 \\ 01 & 01 & 02 & 03 \\ 03 & 01 & 01 & 02 \end{pmatrix}\begin{pmatrix} S_{0,c} \\ S_{1,c} \\ S_{2,c} \\ S_{3,c} \end{pmatrix}}}$

The evaluation of this matrix multiplication is: s′ _(0,c)={02}*s _(0,c)⊕{03}*s _(1,c) ⊕s _(2,c) ⊕s _(3,c) s′ _(1,c) =s _(0,c)⊕{02}*s _(1,c)⊕{03}*s _(2,c) ⊕s _(3,c) s′ _(2,c) =s _(0,c) ⊕s _(1,c)⊕{02}*s _(2,c)⊕{03}s _(3,c) s′ _(3,c)={03}*s _(0,c) ⊕s _(1,c) ⊕s _(2,c)⊕{02}*s _(3,c)

During decryption, the inverse of this operation is required. It is given by the following matrix multiplication.

$\begin{pmatrix} S_{0,c}^{\prime} \\ S_{1,c}^{\prime} \\ S_{2,c}^{\prime} \\ S_{3,c}^{\prime} \end{pmatrix} = {{\begin{pmatrix} b_{0} & b_{3} & b_{2} & b_{1} \\ b_{1} & b_{0} & b_{3} & b_{2} \\ b_{2} & b_{1} & b_{0} & b_{3} \\ b_{3} & b_{2} & b_{1} & b_{0} \end{pmatrix}\begin{pmatrix} S_{0,c} \\ S_{1,c} \\ S_{2,c} \\ S_{3,c} \end{pmatrix}} = {\begin{pmatrix} {0E} & {0B} & {0\; B} & 09 \\ 09 & {0E} & {0E} & {0D} \\ {0D} & 09 & {0E} & {0B} \\ {0B} & {0D} & 09 & {0E} \end{pmatrix}\begin{pmatrix} S_{0,c} \\ S_{1,c} \\ S_{2,c} \\ S_{3,c} \end{pmatrix}}}$

The evaluation of this matrix multiplication is: s′ _(0,c)={0E}*s _(0,c)⊕{0B}*s _(1,c)⊕{0D}*s _(2,c)⊕{09}*s _(3,c) s′ _(1,c)={09}*s _(0,c)⊕{0E}*s _(1,c)⊕{0B}*s _(2,c)⊕{0D}*s _(3,c) s′ _(2,c)={0D}*s _(0,c)⊕{09}*s _(1,c)⊕{0E}*s _(2,c)⊕{0B}*s _(3,c) s′ _(3,c)={0B}*s _(0,c)⊕{0D}*s _(1,c)⊕{09}*s _(2,c)⊕{0E}*s _(3,c)

It is noted that the MixColumns transform matrix has the special property that each successive row is a shifted or rotated version of the preceding row. In general, each element in a row appears in every row but in a different position in the row, and specifically, for the MixColumns transform matrix the different position of each element for each row constitutes a single position right shift or rotation.

According to the present invention, it has been recognised that this property allows the multiplication of each column of the state s to be achieved with significantly reduced hardware.

FIG. 2 illustrates an exemplary embodiment of hardware logic 50 adapted for the multiplication of an m×n matrix by a 1×n matrix, in which the relationship between each successive row of n elements of the m×n matrix is a predetermined row shift. For the AES MixColumns transform, m=4, n=4 and the predetermined relationship is a single right shift.

The logic 50 comprises four 8-bit multiplication circuits 60 . . . 63, four 8-bit XOR gates 70 . . . 73 and four feedback/output registers 80 . . . 83, shown as MixCol₀. . . MixCol₃. Each multiplication circuit 70 . . . 73 is adapted for multiplication of an input by one of the matrix coefficients c₀, c₁, c₂, c₃. Each of the XOR gates 70 . . . 73 may be implemented using any appropriate combination of logic elements required to execute the appropriate logical combination of two inputs, as described hereinafter.

For encryption rounds, the values of c₀. . . c₃ are, respectively, a₀. . . a₃as defined above. For decryption rounds, the values of c₀ . . . c₃ are, respectively, b₀. . . b₃ as defined above. The output of each multiplication circuit 60 . . . 63 is coupled to a first input of a corresponding XOR gate 70 . . . 73. The output of each XOR gate 70 . . . 73 is coupled to a corresponding MixCol register 80 . . . 83. The output of each MixCol register 80 . . . 83 is coupled to the second input of one of the XOR gates 70 . . . 73 according to a feedback plan 90 . . . 93 that corresponds to the row shift function that defines the relationship between successive rows of the matrix. In the present case, the feedback plan 90 . . . 93 implements the right row shift function between successive rows of the matrices a_(r,c) (encryption) and b_(r.c) (decryption)—more generally the matrix c_(r,c).

During operation of the circuit 50, s_(0c), s_(1c), s_(0c), s₀₃ are sequentially offered to the multiplication logic 60 . . . 63 on successive cycles by control means 99. At the outset of each column multiplication, the registers MixCol₀ to MixCol₃ are pre-set to zero.

-   After the 1^(st) cycle:     MixCol₀=c₀.s_(0c)     MixCol₁=c₁.s_(0c)     MixCol₂=c₂.s_(0c)     MixCol₃=c₃.s_(0c) -   After the 2^(nd) cycle:     MixCol₀=c₀.s_(1c)⊕c₁.s_(0c)     MixCol₁=c₁.s_(1c)⊕c₂.s_(0c)     MixCol₂=c₂.s_(1c)⊕c₃.s_(0c)     MixCol₃=c₃.s_(1c)⊕c₀.s_(0c) -   After the 3^(rd) cycle:     MixCol₀=c₀.s_(2c)⊕c₁.s_(1c)⊕c₂.s_(0c)     MixCol₁=c₁.s_(2c)⊕c₂.s_(1c)⊕c₃.s_(0c)     MixCol₂=c₂.s_(2c)⊕c₃.s_(1c)⊕c₀.s_(0c)     MixCol₃=c₃.s_(2c)⊕c₀.s_(1c)⊕c₁.s_(0c) -   After the 4^(th) cycle:     MixCol₀=c₀.s_(3c)⊕c₁.s_(2c)⊕c₂.s_(1c)⊕c₃.s_(0c)     MixCol₁=c₁.s_(3c)⊕c₂.s_(2c)⊕c₃.s_(1c)⊕c₀.s_(0c)     MixCol₂=c₂.s_(3c)⊕c₃.s_(2c)⊕c₀.s_(1c)⊕c₁.s_(0c)     MixCol₃=c₃.s_(3c)⊕c₀.s_(2c)⊕c₁.s_(1c)⊕c₂.s_(0c)     Rearranging these outputs, according to the feedback plan 90 . . .     93 gives the outputs:

MixCol₁=s′_(0,c)

MixCol₂=s′_(1,c)

MixCol₃=s′_(2,c)

MixCol₀=s′_(0,c)

which is the required result.

It will be noted that, generally speaking, the number of rows, m, in the matrix determines the number of cycles required, while the number of columns, n, determines the number of logic groups (multipliers 60 . . . 63, XOR gates 70 . . . 73, and registers 80 . . . 83) required.

The multiplication logic 60 . . . 63 can be implemented using any suitable logic. In a preferred embodiment, the logic is provided for both encryption and decryption combining certain logic according to the following schedule.

For c₀×s_(0,c), there the output from the respective multiplication logic 60 . . . 63 is defined as e_(cycle, bit), and d=0 for encryption and d=1 for decryption: e ₀₇ =s ₆ XNOR NAND(d, s ₄₅) e ₀₆ =s ₅ XNOR NAND(d, s ₃₄₇) e ₀₅ =s ₄ XNOR NAND(d, s ₂₃₆) e ₀₄ =s ₃₇ XNOR NAND(d, s ₁₂₅) e ₀₃ =s ₂₇ XNOR NAND(d, s ₀₁₅₇) e ₀₂ =s ₁₇ XNOR NAND(d, s ₀₅₆₇) e ₀₁ =s ₀ XNOR NAND(d, s ₆₇) e ₀₁ =s ₇ XNOR NAND(d, s ₅₆)

Similarly, for c₁×s_(1,c): e ₁₇ =s ₇ XNOR NAND(d, s ₄) e ₁₆ =s ₆ XNOR NAND(d, s ₃₇) e ₁₅ =s ₅ XNOR NAND(d, s ₂₆₇) e ₁₄ =s ₄ XNOR NAND(d, s ₁₅₆₇) e ₁₃ =s ₃ XNOR NAND(d, s ₀₅₆) e ₁₂ =s ₂ XNOR NAND(d, s ₅₇) e ₁₁ =s ₁ XNOR NAND(d, s ₆) e ₁₀ =s ₀ XNOR NAND(d, s ₅)

Similarly, for c₂×s_(2, c): e ₂₇ =s ₇ XNOR NAND(d, s ₄₅) e ₂₆ =s ₆ XNOR NAND(d, s ₃₄₇) e ₂₅ =s ₅ XNOR NAND(d, s ₂₃₆) e ₂₄ =s ₄ XNOR NAND(d, s ₁₂₅) e ₂₃ =s ₃ XNOR NAND(d, s ₀₁₅) e ₂₂ =s ₂ XNOR NAND(d, s ₀₅₆₇) e ₂₁ =s ₁ XNOR NAND(d, s ₆₇) e ₂₀ =s ₀ XNOR NAND(d, s ₅₆)

Similarly, for c₃ ×s _(3,c): e ₃₇ =s ₆₇ XNOR NAND(d, s ₄) e ₃₆ =s ₅₆ XNOR NAND(d, s ₃₇) e ₃₅ =s ₄₅ XNOR NAND(d, s ₂₆₇) e ₃₄ =s ₃₄₇ XNOR NAND(d, s ₁₅₆₇) e ₃₃ =s ₂₃ XOR s ₇ XNOR NAND(d, s ₀₅₆) e ₃₂ =s ₁₂ XOR s ₇ XNOR NAND(d, s ₅₇) e ₃₁ =s ₀₁ XNOR NAND(d, s ₆) e ₃₀ =s ₀₇ XNOR NAND(d, s ₅)

where: a₅₇=a₅ XOR a₇ a₀₇=a₀ XOR a₇ a₃₄=a₃ XOR a₄ a₅₆₇=a₇ XOR a₅₆ a₁₂₅=a₁₂ XOR a₅ a₁₅₆₇=a₁₇ XOR a₅₆ a₃₇=a₃ XOR a₇ a₆₇=a₆ XOR a₇ a₂₃=a₂ XOR a₃ a₀₅₆=a₀ XOR a₅₆ a₂₆₇=a₂ XOR a₆₇ a₂₇=a₂ XOR a₇ a₅₆=a₅ XOR a₆ a₁₂=a₁ XOR a₂ a₃₄₇=a₃₄ XOR a₇ a₀₁₅₇=a₀₁ XOR a₅₇ a₁₇=a₁ XOR a₇ a₄₅=a₄ XOR a₅ a₀₁=a₀ XOR a₁ a₂₃₆=a₂₃ XOR a₆ a₀₅₆₇=a₀₇ XOR a₅₆

This requires 23 XOR gates, 32 XNOR gates and 32 NAND gates.

Other embodiments are intentionally within the scope of the accompanying claims. 

1. A logic circuit for encrypting and decrypting data including shifting in a MixColumn transform by multiplication of an (m×n) matrix of data by a (1×n) or by a (m×1)matrix, where m is a number of rows and n is a number of columns, and wherein each successive row m of n elements is a predetermined row permutation of a preceding row, the circuit comprising: n multiplication circuits for performing a multiplication function on a value of data, each n multiplication circuit having data input for receiving input data and an output for outputting a changed value of the data received by said input, the output value of the data comprising the input data that has been multiplied by a predetermined multiplicand; n logic circuits, each logic circuit comprising at least a first input and a second input for executing a predetermined logical combination of the first input and the second input to provide a logical output, the first input being coupled to the output of a corresponding one of the n multiplication circuits; n registers coupled to said n logic circuits for receiving and storing said logical output from a respective logic circuit; feedback logic for routing stored contents of each register to a selected one of the second inputs of said n logic circuits in accordance with a feedback plan that corresponds to a predetermined row permutation; and control means for successively providing a data input to each of the n multiplication circuits for each element in the (1×n) or (m×1) matrix; and wherein said n registers in accordance with said feedback logic having a data-shifted output of the data input by the control means, the data-shifted output in each of the n registers having a state “s” for remaining encryption or decryption operations.
 2. The logic circuit of claim 1 in which the feedback logic provides a feedback plan corresponding to said predetermined row permutation that is a row shift.
 3. The logic circuit of claim 2 in which the row shift is a single element right shift.
 4. The logic circuit of claim 1 in which the n logic circuits are each adapted to execute an XOR-combination of said first input and said second input.
 5. The logic circuit of claim 1 in which each of the predetermined multiplicands corresponds to one of the elements in the AES Rijndael MixColumns transform function.
 6. The logic circuit of claim 5 in which the number m=4, the number n=4, the multiplicand for the first multiplication circuit=02, the multiplicand for the second multiplication circuit=03, the multiplicand for the third multiplication circuit=01, and the multiplicand for the fourth multiplication circuit=01.
 7. The logic circuit of claim 5 in which the number m=4, the number n=4, the multiplicand for the first multiplication circuit=0E, the multiplicand for the second multiplication circuir=0B, the multiplicand for the third multiplication circuit=0D, and the multiplicand for the fourth multiplication circuit=09.
 8. The logic circuit of claim 6, in which the four multiplicands are switched between the values in claim
 6. 9. The logic circuit of claim 1 in which the control means is adapted to successively provide as input to each of the n multiplication circuits each successive element in the (1.times.n) or (m.times.1) matrix over each of n or m cycles of operation respectively.
 10. The logic circuit of claim 1 in which each of the n multiplication circuits, each of the n logic circuits, and each of the n registers are at least eight bits wide.
 11. The logic circuit of claim 1 in which the control means further includes means for providing as output from said logic circuit the contents of the n registers after each nth cycle.
 12. The logic circuit of claim 1 in which the control means further includes means for resetting each of the registers prior to the first calculation cycle.
 13. The logic circuit of claim 1 in which each successive row m of n elements is a predetermined row permutation of the immediately preceding row.
 14. An AES MixColumns transform circuit incorporating the logic circuit of claim
 1. 15. A smartcard comprising the logic circuit according to claim
 1. 16. An AES encryption and/or decryption engine incorporating the logic circuit for performing the MixColumns transform, said logic circuit for multiplication of an matrix by a or by a matrix, where m is a number of rows and n is a number of columns, and wherein each successive row m of n elements is a predetermined row permutation of a preceding row, the circuit comprising: n multiplication circuits each having an input and an output which returns the value of said input multiplied by a predetermined multiplicand; n logic circuits, each for executing a predetermined logical combination of a first input and a second input to provide a logical output, the first input being coupled to the output of a corresponding one of the n multiplication circuits: n registers for receiving said logical output; feedback logic for routing the contents of each register to a selected one of the second inputs in accordance with a feedback plan that corresponds to the predetermined row permutation; and control means for successively providing as input to each of the n multiplication circuits each element in the or matrix.
 17. A method for encrypting and decrypting data including shifting in a MixColumn transform by multiplication of an (m×n) matrix of data by a (1×n) or by a (m×1) matrix, where m is a number of rows and n is a number of columns, and wherein each successive row m of n elements is a predetermined row permutation of a preceding row, comprising the steps of: successively providing an input to each of n multiplication circuits for each element in the (1×n) or (m×1) matrix by a control means; performing a multiplication function by “n” multiplication circuits on a value of data, each n multiplication circuit having a data input for receiving data and an output for outputting a changed value of the data received by said input, the changed value of the data comprising input data that has been multiplied by a predetermined multiplicand; executing a predetermined logical combination by n logic circuits to provide a logical output, each logic circuit comprising at least a first input and a second input, the first input being coupled to an output of a corresponding one of the n multiplication circuits; receiving and storing said logical output from a respective logic circuit of n logic circuits by a register from a plurality of n registers, n registers being coupled to said n logic circuits; routing the contents of each register to a selected one of the second inputs of said n logic circuits by feedback logic in accordance with a feedback plan that corresponds to a predetermined row permutation; and storing a data-shifted output of the data input by the control means, the data-shifted output in each of the n registers received by the n registers in accordance with the feedback logic, and the data-shifted output having a state “s” for use in remaining encryption or decryption operations. 